package com.charles.config;

import com.charles.aspect.SignAspect;
import com.charles.request.RequestBodyReaderFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;

/**
 * @author charles
 * @date 2023/5/7 18:28
 */
public class SignAutoConfiguration {

    @Bean
    public SignAspect signAspect() {
        return new SignAspect();
    }

    @Bean
    public FilterRegistrationBean<RequestBodyReaderFilter> requestBodyReaderFilter() {
        FilterRegistrationBean<RequestBodyReaderFilter> registrationBean = new FilterRegistrationBean<>();
        RequestBodyReaderFilter filter = new RequestBodyReaderFilter();
        registrationBean.setFilter(filter);
        ArrayList<String> urls = new ArrayList<>();
        urls.add("/*");//配置过滤规则
        registrationBean.setUrlPatterns(urls);
        registrationBean.setOrder(3);
        return registrationBean;
    }
}
